﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Project
{
    public partial class YGtian : Form
    {
        public YGtian()
        {
            InitializeComponent();
        }

        private void label9_Click(object sender, EventArgs e)
        {

        }

        private void label6_Click(object sender, EventArgs e)
        {

        }

        private void label6_Click_1(object sender, EventArgs e)
        {

        }

        private void YGtian_Load(object sender, EventArgs e)
        {
            string sql = "select * from Branch";
            DataTable dt = FrmHotel.DBHelper.SelectForTable(sql);
            this.comboBox2.DisplayMember = "BranchName";
            this.comboBox2.ValueMember = "BranchId";
            this.comboBox2.DataSource = dt;


            string sql1 = "select * from EyState";
            DataTable dt1 = FrmHotel.DBHelper.SelectForTable(sql1);
            this.comboBox1.DisplayMember = "ESName";
            this.comboBox1.ValueMember = "ESId";
            this.comboBox1.DataSource = dt1;

                
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string name = this.textBox2.Text;
            string sex = this.textBox4.Text;
            string birthday = this.dateTimePicker1.Value.ToString("yyyy-MM-dd");
            int gId = Convert.ToInt32(this.comboBox2.SelectedValue);
            string workday = this.dateTimePicker2.Value.ToString("yyyy-MM-dd");
            string phone = this.textBox5.Text;
            string address = this.textBox3.Text;
            int workId = Convert.ToInt32(this.comboBox2.SelectedValue);
            if(string.IsNullOrEmpty(name)||string.IsNullOrEmpty(address)||string.IsNullOrEmpty(phone))
            {
                MessageBox.Show("请填写完整");
                return;
            }
            string sql = string.Format("insert into EyInfo values('{0}','{1}','{2}',{3},'{4}','{5}','{6}',{7})",name,sex,birthday,gId,workday,phone,address,workId);
            int result = FrmHotel.DBHelper.ExecuteUpdate(sql);
            if (result > 0)
            {
                MessageBox.Show("添加成功");
                this.Close();
            }
            else 
            {
                MessageBox.Show("添加失败");
            }



        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
